home *** CD-ROM | disk | FTP | other *** search
- Path: in1.uu.net!interaccess!usenet
- From: brianmcg@interaccess.com (Brian V. McGroarty)
- Newsgroups: comp.lang.c
- Subject: Re: Help ! Please help me solve the problem
- Date: 21 Mar 1996 14:13:48 GMT
- Organization: Internet Squire
- Message-ID: <4iro6s$2e9@nntp.interaccess.com>
- References: <4iltc9$3sa@ctylnk.cityu.edu.hk>
- Reply-To: brianmcg@interaccess.com
- NNTP-Posting-Host: d222.nhe.interaccess.com
- X-Newsreader: Internet Squire 1.20
-
- Note that much of your post is Intel '86 specific. You may get better
- results on future questions if you follow up in an MS-DOS programming
- group. /* not a flame */
-
-
- To call your old function, you will need to first store the vector to the
- old function. With several MS-DOS compilers, I have used:
-
- void interrupt ( *oldInterruptFunction )();
-
- void interrupt InterruptFunction()
- {
- /* do stuff */
-
- oldInterruptFunction(); /* call old function */
- }
-
- void InstallRoutine()
- {
- oldInterruptFunction= VectorGetRoutine( 13 );
- VectorSetRoutine( NewInterruptFunction, 13 );
- }
-
-
- If you find that you cannot see your data, consider declaring the data as
- "far" or "huge" in order to avoid the implicit data segment. If your
- compiler doesn't restore the DS on return, you should store your DS in a
- far data item and store and restore it, i.e.
-
- short int far myDS;
-
- void Installer()
- {
- short int fetchDS; /* don't assume format of far ptr */
-
- asm {
- mov ax,ds
- mov fetchDS, ax
- }
- myDS= fetchDS;
-
- /* install interrupt vector here */
- }
-
- void interrupt InterruptRoutine()
- {
- short int holdDS, fetchDS;
-
- asm { /* fetch original DS */
- mov ax,ds
- mov holdDS, ax
- }
- fetchDS= myDS;
- asm {
- mov ax, fetchDS
- mov ds, ax
- }
-
- /* do your work here */
-
- asm { /* restore interrupt DS */
- mov ax, holdDS
- mov ds, ax
- }
-
- oldInterruptFunction();
- }
-
- Note that you may need to explicitly set ES too!
-
-
- Maxeller wrote:
- > I want to write a disk cache program and so must place my new interrupt
- > point into interrupt vector 13 which points to my new function.
-
- > Please take a look at my simple test program please:
-
- > unsign long old_int_pointer;
-
- > new_int_function()
- > {
-
-
- > /* just jump to old_int_pointer which read from disk
- > because it is a test program so nothing others is done */
-
- > }
-
- > main()
- > {
- > /* save old int13 pointer into old_int_pointer
- > using int21h ax=3513 */
-
- > /* put address of new_int_function() into vector 13 area
- > using int21h ax=2513 */
-
- > /* TSR function goes here */
-
- > }
-
- > Save and put new interrupt address and TSR is OK.
-
- > However when disk reading is involved, it hangs.
-
- > My problem is :
- > 1) what code should write so it can jump to my
- > old_int_pointer. I have though for a long time!! :-(
- > 2) I am afraid that when control is passed to new_int_function,
- > it can not retrieve values such as old_int_pointer because
- > the segment register may not match as that in my program.
-
- ---
- Brian Valters McGroarty -- brianmcg@bix.com
- phone/fax (847) 439-7714
-